package cn.da.shuai.cool.common.util;

import cn.da.shuai.cool.common.entity.Page;

public class PageUtil {
    private static final ThreadLocal<Page> pageThreadLocal = new ThreadLocal<>();

    public static void setPage(int pageNum, int pageSize) {
        pageThreadLocal.set(new Page(pageNum, pageSize));
    }

    public static int getPageNum() {
        if (pageThreadLocal.get() == null) {
            return -1;
        }
        return pageThreadLocal.get().getPageNum();
    }

    public static int getPageSize() {
        if (pageThreadLocal.get() == null) {
            return -1;
        }
        return pageThreadLocal.get().getPageSize();
    }

    public static void clearPage() {
        pageThreadLocal.remove();
    }

}


